package Serverimpl;


import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class SimpleServer {
    public  static  void main(String[] args){
        try {
            ServerSocket ss = new ServerSocket(12345);
            Socket socket = ss.accept();
            System.out.println("Client connected");

            OutputStream os = socket.getOutputStream();
            ObjectOutputStream oos = new ObjectOutputStream(os);

            ObjectInputStream ois = new ObjectInputStream(socket.getInputStream());
            System.out.println("2");

            while(true){
                try {
                    System.out.println("Ready for reading...");
                    Object obj = ois.readObject();
                    System.out.println(obj);
                    oos.writeObject(obj);
                } catch (ClassNotFoundException e) {
                    System.out.println("ClassNotFound in server, when reading from client");
                }
            }
        } catch (IOException e) {
            System.out.println("IOException in server ");
            e.printStackTrace();
        }

    }
}
